<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // toFixed()设置保留小数位的长度  四舍五入

    const num1 = 10.123
    const num2 = 10.923
    const num3 = 10

    console.log(num1.toFixed())  // 10
    console.log(num2.toFixed())  // 11

    console.log(num2.toFixed(2))  // 10.92
    console.log(num2.toFixed(1))  // 10.9

    console.log(num3.toFixed(2))  // 10.00
  </script>
</body>

</html>